<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<?php $this->load->view('common/head');?>
<body class="no-skin">
<?php $this->load->view('common/header');?>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <?php $this->load->view('common/sidebar');?>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <?php $this->load->view('common/breadcrumbs');?>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">

                <?php $this->load->view('common/set');?>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form class="form-horizontal" action="<?php echo site_url(X_URL.'defray/update');?>" method="post">
                            <?php echo csrf_hidden();?>
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 使用场景 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="defray_title" id="defray_title" placeholder="使用场景" class="col-xs-10 col-sm-5"
                                           value="">
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 申请金额 </label>
                                <div class="input-group col-sm-3" style="padding-left: 15px;">
                                    <input type="text" class="form-control input-mask-product" name='defray_money'  id="defray_money"  placeholder="申请金额">
                                    <span class="input-group-addon">
                                        <i class="ace-icon fa fa-rmb bigger-100 "></i>
                                    </span>
                                </div>

                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 使用时间 </label>
                                <div class="input-group col-sm-3" style="padding-left: 15px;">
                                    <input type="text" class="form-control input-mask-product" name='defray_time'  id="defray_time" placeholder="<?php if(!empty($project['project_start_time'])){  echo $project['project_start_time'];}?>" placeholder="yyyyMM">
                                    <span class="input-group-addon">
                                        <i class="ace-icon fa fa-calendar bigger-100 "></i>
                                    </span>
                                </div>

                            </div>
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 上传凭证 </label>
                                <div class="upload_wrapper">
                                    <div class="upload icon_upload" style="margin-left: 15px;">
                                        <input type="file" />
                                        <i class="add_icon"></i>
                                        <p>上传</p>
                                    </div>
                                </div>

                            </div>
                            <input type="hidden" value="" id="defray_pic" name="defray_pic">
                            <div class="col-md-offset-2 col-md-9">
                                <button class="btn btn-info" type="submit">
                                    <i class="icon-ok bigger-110"></i>
                                    提交
                                </button>
                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="reset">
                                    <i class="icon-undo bigger-110"></i>
                                    重置
                                </button>
                            </div>
                        </form>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <?php $this->load->view('common/footer');?>
</div><!-- /.main-container -->

<?php $this->load->view('common/footerjs');?>
<?php echo admin_js_url('laydate');?>
<?php echo admin_js_url("jquery.core.image.upload.min")?>
<!-- inline scripts related to this page -->
<script type="text/javascript">

    $(".icon_upload").coreImageUpload ({
        url: baseurl+'index.php/manage/defray/upload_pic?name=icon_pic',
        inputOfFile: 'icon_pic',
        uploadedCallback: function (result) {
            if(result.status==1){
                var img = '<img style="width: 120px;height: 120px;" src="'+result.url+'">';
                $(".icon_upload img").remove();
                $(".icon_upload i").remove();
                $(".icon_upload p").remove();
                $(".icon_upload input").after(img);
                $("#defray_pic").val(result.path);
            }else{
                layer.msg(result.msg,{offset:"80px"});
            }
        }
    });
    $(function () {
        lay('#version').html('-v'+ laydate.v);
        laydate.render({
            elem: '#defray_time' //指定元素
        });

        $(".btn-info").click(function () {
            var defray_title = $("#defray_title").val();
            var defray_time = $("#defray_time").val();
            var defray_nomey = $("#defray_nomey").val();
            var defray_pic = $("#defray_pic").val();
            if(defray_title== ''){
                bootbox.dialog({
                    title:"系统提示",
                    message: "使用场景需要填写",
                    buttons: {
                        "success": {
                            "label": "确定",
                            "className": "btn-danger"
                        }
                    }
                });
                return false;
            }
            if(defray_time== ''){
                bootbox.dialog({
                    title:"系统提示",
                    message: "使用时间需要填写",
                    buttons: {
                        "success": {
                            "label": "确定",
                            "className": "btn-danger"
                        }
                    }
                });
                return false;
            }
            if(defray_nomey== ''){
                bootbox.dialog({
                    title:"系统提示",
                    message: "申请金额必须填写",
                    buttons: {
                        "success": {
                            "label": "确定",
                            "className": "btn-danger"
                        }
                    }
                });
                return false;
            }
            if(defray_pic== ''){
                bootbox.dialog({
                    title:"系统提示",
                    message: "凭证必须上传",
                    buttons: {
                        "success": {
                            "label": "确定",
                            "className": "btn-danger"
                        }
                    }
                });
                return false;
            }


            $("#form").submit();
        })
    })

</script>
</body>
</html>
